<!DOCTYPE html>
<html>
<head>
    <title>Physics Diagram - Helium Phases</title>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background-color: #f0f0f0;
        }
        canvas {
            border: 1px solid #ccc;
            background-color: #fff;
        }
    </style>
</head>
<body>
    <canvas id="physicsCanvas" width="600" height="300"></canvas>
    <script>
        const canvas = document.getElementById('physicsCanvas');
        const ctx = canvas.getContext('2d');

        // Style settings
        const primaryFont = "18px 'Comic Sans MS', 'Trebuchet MS', sans-serif";
        const primaryColor = "black";
        ctx.fillStyle = primaryColor;
        ctx.strokeStyle = primaryColor;
        
        // --- Draw Container and Phases ---
        const containerX = 50;
        const containerY = 75;
        const containerWidth = 250;
        const containerHeight = 100;

        // Draw the main container
        ctx.lineWidth = 2;
        ctx.strokeRect(containerX, containerY, containerWidth, containerHeight);

        // Draw the phase boundary line
        const boundaryY = containerY + containerHeight / 2;
        ctx.beginPath();
        ctx.moveTo(containerX, boundaryY);
        ctx.lineTo(containerX + containerWidth, boundaryY);
        ctx.stroke();

        // --- Draw the dilute phase stippling ---
        const numDots = 150;
        const dotRadius = 1.2;
        ctx.fillStyle = primaryColor;
        for (let i = 0; i < numDots; i++) {
            // Random position within the bottom half of the container
            const x = containerX + 3 + Math.random() * (containerWidth - 6);
            const y = boundaryY + 3 + Math.random() * (containerHeight / 2 - 6);
            
            ctx.beginPath();
            ctx.arc(x, y, dotRadius, 0, 2 * Math.PI);
            ctx.fill();
        }

        // --- Draw Labels and Pointers ---
        ctx.font = primaryFont;
        ctx.textAlign = 'left';
        ctx.lineWidth = 1;

        // Label for the concentrated phase (top)
        const labelTopY = containerY + containerHeight / 4;
        const labelTopText = "concentrated phase of \u00B3He";
        const labelTopX = containerX + containerWidth + 15;
        
        ctx.beginPath();
        ctx.moveTo(containerX + containerWidth, labelTopY);
        ctx.lineTo(labelTopX - 5, labelTopY);
        ctx.stroke();
        ctx.fillText(labelTopText, labelTopX, labelTopY + 5);

        // Label for the dilute phase (bottom)
        const labelBottomY = boundaryY + containerHeight / 4;
        const labelBottomText1 = "dilute phase of \u00B3He";
        const labelBottomText2 = "(in superfluid of \u2074He)";
        const labelBottomX = containerX + containerWidth + 15;

        ctx.beginPath();
        ctx.moveTo(containerX + containerWidth, labelBottomY);
        ctx.lineTo(labelBottomX - 5, labelBottomY);
        ctx.stroke();
        ctx.fillText(labelBottomText1, labelBottomX, labelBottomY - 5);
        ctx.fillText(labelBottomText2, labelBottomX, labelBottomY + 18);
        
        // --- Draw Figure Caption ---
        ctx.textAlign = 'center';
        const captionText = "Fig. 2.23.";
        const captionX = containerX + containerWidth / 2;
        const captionY = containerY + containerHeight + 40;
        ctx.fillText(captionText, captionX, captionY);

    </script>
</body>
</html>